using System;
using System.Collections;

namespace Fuse8.DomainFramework.Practices.SystemFacade.Extensions
{
	internal static class TypeExtensions
	{
		public static bool IsSimpleType(this Type type)
		{
			return type.IsValueType || (type == typeof(string)) || (type == typeof(byte[]));
		}

		public static bool IsEnumerable(this Type type)
		{
			return typeof(IEnumerable).IsAssignableFrom(type);
		}

		public static bool IsNullable(this Type type)
		{
			return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
		}

		public static bool CanBeNull(this Type type)
		{
			return !type.IsValueType || (Nullable.GetUnderlyingType(type) != null);
		}
	}
}